/*
 * Copyright (c) 2003-2007 by Observant Pty. Ltd. All rights reserved.
 *
 * Redistribution or reproduction of part or all of the contents of
 * this file in any form is prohibited.
 *
 */
package com.ctn.util.dao;

import java.util.List;

public class ResourceQueryResult<T> {
    List<T> records;
    int totalRecordCount;
    int start;
    int limit;
    int recordCount;
    transient ResourceQuery query;
    public ResourceQueryResult(ResourceQuery query, List<T> records, int totalRecordCount, int start, int limit) {
        super();
        this.query = query;
        this.records = records;
        this.totalRecordCount = totalRecordCount;
        this.start = start;
        this.limit = limit;
        this.recordCount = records.size();
    }
    public List<T> getRecords() {
        return records;
    }
    public void setRecords(List<T> records) {
        this.records = records;
    }
    public int getTotalRecordCount() {
        return totalRecordCount;
    }
    public void setTotalRecordCount(int totalRecordCount) {
        this.totalRecordCount = totalRecordCount;
    }
    public int getStart() {
        return start;
    }
    public int getLimit() {
        return limit;
    }
    public int getRecordCount() {
        return recordCount;
    }
    public ResourceQuery getQuery() {
        return query;
    }
    /**
     * @return the query result in the form specified in the query. Either the list of resources or the entire query result (which includes result meta-data & resources)
     */
    public Object getResultsInRequestedForm() {
        return getQuery().isWrapResult()? this: this.getRecords();
    }
}